package io.renren.modules.combat.controller;


import io.renren.common.utils.PageUtils;
import io.renren.modules.combat.service.TFightPeopleService;
import io.renren.modules.user.entity.form.PeopleEntityForm;
import io.renren.modules.user.entity.form.PeopleForm;
import io.swagger.models.Model;
import net.bytebuddy.agent.builder.AgentBuilder;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.renren.modules.combat.entity.TFightPeopleEntity;

import io.renren.modules.combat.entity.TFightInformationEntity;
import io.renren.modules.combat.service.TFightInformationService;
import io.renren.common.utils.R;

import java.util.*;
import java.util.List;



/**
 * 战斗信息
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2019-08-02 10:30:00
 */
@RestController
@RequestMapping("/tfightinformation")
public class TFightInformationController {
    @Autowired
    private TFightInformationService tFightInformationService;
    @Autowired
    private TFightPeopleService tFightPeopleService;


    /**
     * 编辑
     */
    @RequestMapping("/info")
    //@RequiresPermissions("combat:tfightinformation:info")
    public R info(@RequestBody TFightPeopleEntity tf,Model model){
		TFightInformationEntity tFightInformation = tFightInformationService.bjTFightInformationEntity(tf.getId());
		List<TFightPeopleEntity> list = tFightInformationService.getTFightPeopleEntity(tf.getId());
        List<TFightPeopleEntity> arrer= tFightInformationService.getArrer();   //区域
        List<TFightPeopleEntity> type = tFightInformationService.getType();    //战斗类型
        return R.ok().put("tFightInformation", tFightInformation).put("list",list).put("arrer",arrer).put("type",type);
    }
    /**
     * 下拉框 接口
     */
    @RequestMapping("/xlk")
    //@RequiresPermissions("combat:tfightinformation:xlk")
    public R xlk(TFightPeopleEntity peopleEntity){
        List<TFightPeopleEntity> arrer= tFightInformationService.getArrer();   //区域
        List<TFightPeopleEntity> type = tFightInformationService.getType();    //战斗类型
        List<TFightPeopleEntity> object=tFightInformationService.getObject(peopleEntity);   //战斗项目
        TFightInformationEntity ight =tFightInformationService.getTFightId();   //获取战斗id
        int num=ight.getId()+1;
        return R.ok().put("arrer",arrer).put("type",type).put("object",object).put("id",num);
    }

    /**
     * 下拉框 战斗项目
     */
    @RequestMapping("/getObject")
    public R getObject(@RequestBody TFightPeopleEntity peopleEntity){
        List<TFightPeopleEntity> object=tFightInformationService.getObject(peopleEntity);   //战斗项目
        return R.ok().put("object",object);
    }
    /**
     * 保存  战斗信息表  和 战斗人员表(批量)
     */
    @RequestMapping("/save")
    @ResponseBody
    @RequiresPermissions("combat:tfightinformation:save")
    public R save(@RequestBody TFightInformationEntity tFightInformation){
		tFightInformationService.addTFightInformationEntity(tFightInformation);    //添加战斗信息
        tFightInformationService.addTFightPeopleEntity(tFightInformation.getList());    //批量添加战斗人员
        return R.ok();
    }

    /**
     * 修改  修改战斗信息表   和 战斗人员表(批量)
     */
    @RequestMapping("/update")
    @ResponseBody
    @RequiresPermissions("combat:tfightinformation:update")
    public R update(@RequestBody TFightInformationEntity tFightInformation){
		tFightInformationService.updateTFightInformationEntity(tFightInformation);     //战斗信息
        Integer num=tFightInformation.getList().size();
        for(int i=0;i<num;i++){
            Integer sum= tFightInformation.getList().get(i).getId();
            if(tFightInformation.getList().get(i).getId()==null){
                TFightPeopleEntity list=tFightInformation.getList().get(i);
                list.setFightId(tFightInformation.getId());
                tFightInformationService.insertTFightPeople(list);
            }else{
               TFightPeopleEntity list=tFightInformation.getList().get(i);
                List<TFightPeopleEntity> li=new ArrayList<>();
                li.add(list);
                tFightInformationService.updateTFightPeopleEntity(li);    //战斗人员
            }
        }

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @ResponseBody
    @RequiresPermissions("combat:tfightinformation:delete")
    public R delete(@RequestBody TFightInformationEntity tFightInformation){
		tFightInformationService.delTFightInformationEntity(tFightInformation.getId());
        return R.ok();
    }

    /**
     * 列表
     */
    @RequestMapping("/listTFightInformationEntity")
    @ResponseBody
    @RequiresPermissions("combat:tfightinformation:listTFightInformation")
    public R getList(@RequestBody TFightInformationEntity queryWrapper){
        String sql = this.doSql(queryWrapper.getPeopleEntityForms(),queryWrapper.getFlag());
        Map<String,Object> params=new HashMap<String,Object> ();
        String sqls=null;
        if(!sql.equals("")){
            String a=sql.substring(0,3);
            if("and".equals(a)){
                sqls = deleteAssignChar(sql, 0, 'a');
                String sa = deleteAssignChar(sqls, 1, 'a');
                String sb = deleteAssignChar(sa, 1, 'n');
                sqls = deleteAssignChar(sb, 1, 'd');
            }
            if("or ".equals(a)){
                sqls = deleteAssignChar(sql, 0, 'o');
                String sa = deleteAssignChar(sqls, 1, 'o');
                sqls = deleteAssignChar(sa, 1, 'r');
            }
            System.out.print(sqls);
        }
        params.put("sqls",sqls);
        params.put("page",queryWrapper.getPage());
        params.put("limit",queryWrapper.getLimit());
        params.put("name",queryWrapper.getName());
        params.put("detachment",queryWrapper.getDetachment());
        params.put("month",queryWrapper.getMonth());
        params.put("zmonth",queryWrapper.getZmonth());
        params.put("type",queryWrapper.getType());
        params.put("type1",queryWrapper.getType1());
        params.put("type2",queryWrapper.getType2());
        params.put("yearTime",queryWrapper.getYearTime());
        params.put("squadron",queryWrapper.getSquadron());
        Integer types=queryWrapper.getTypes();
        params.put("types",types);
        PageUtils page = tFightInformationService.getTFightInformationEntity(params);
        return R.ok().put("page", page);
    }


    public static String deleteAssignChar(String str, int on, char c){
        int count = 0;
        for(int i=0;i<str.length();i++){
            if(str.charAt(i) == c){
                count++;
                if(count == on){
                    str = str.substring(0, i) + str.substring(i + 1);
                }
            }
        }
        return str;
    }



    /**
     * 统计 战斗类型
     */
    @RequestMapping("/getZDLX")
    @ResponseBody
    //@RequiresPermissions("combat:tfightinformation:getZDLX")
    public R getZDLX(){
        List<TFightInformationEntity> zdlx=tFightInformationService.getZDLX();
        return R.ok().put("zdlx", zdlx);
    }

    /**
     * 统计 战斗 区域
     */
    @RequestMapping("/getZDQY")
    @ResponseBody
    //@RequiresPermissions("combat:tfightinformation:getZDQY")
    public R getZDQY(){
        List<TFightInformationEntity> zdqy=tFightInformationService.getZDQY();
        return R.ok().put("zdqy", zdqy);
    }



    /**
     * 分布图 战斗头部统计
     */
    @RequestMapping("/totalCombatHeadCount")
    @ResponseBody
    //@RequiresPermissions("combat:tfightinformation:getZdsy")
    public R totalCombatHeadCount(@RequestBody TFightInformationEntity tFightInformationEntity){
        List<TFightInformationEntity> list=tFightInformationService.totalCombatHeadCount(tFightInformationEntity);
        return R.ok().put("list", list);
    }
    /**
     * 战斗首页 支队
     */
    @RequestMapping("/getZdsy")
    @ResponseBody
    //@RequiresPermissions("combat:tfightinformation:getZdsy")
    public R getZdsy(@RequestBody TFightInformationEntity tFightInformationEntity){
        List<TFightInformationEntity> zdqy=tFightInformationService.getZdsy(tFightInformationEntity);
        return R.ok().put("zdqy", zdqy);
    }

    /**
     * 战斗首页 中队
     */
    @RequestMapping("/getZdsyZd")
    @ResponseBody
    //@RequiresPermissions("combat:tfightinformation:getZdsy")
    public R getZdsyZd(@RequestBody TFightInformationEntity tFightInformationEntity){
        List<TFightInformationEntity> zdqy=tFightInformationService.getZdsyZd(tFightInformationEntity);
        return R.ok().put("zdqy", zdqy);
    }

    /*
     *人员信息查询
     * */
    @RequestMapping("/peoplelists")
    //  @RequiresPermissions("user:tpeople:list")
    public R peoplelist(@RequestBody PeopleForm peopleEntityVo){
        Map<String,Object> params=new HashMap<String,Object> ();
        params.put("page",peopleEntityVo.getPage());
        params.put("limit",peopleEntityVo.getLimit());
        params.put("likeName",peopleEntityVo.getLikeName());
        params.put("detachment",peopleEntityVo.getDetachment());
        params.put("squadron",peopleEntityVo.getSquadron());
        params.put("peopleType",peopleEntityVo.getPeopleType());
        PageUtils page = tFightInformationService.queryList(params);
        return R.ok().put("page", page);
    }

    /**
     * 战斗头部 所有中队总计
     */
    @RequestMapping("/totalCombatSquadron")
    @ResponseBody
    //@RequiresPermissions("combat:tfightinformation:getZdsy")
    public R totalCombatSquadron(@RequestBody TFightInformationEntity tFightInformationEntity){
        List<TFightInformationEntity> list=tFightInformationService.totalCombatSquadron(tFightInformationEntity);
        return R.ok().put("list", list);
    }
    /**
     * 战斗头部 所有支队总计
     */
    @RequestMapping("/totalCombatDetachment")
    //@RequiresPermissions("combat:tfightinformation:getZdsy")
    public R totalCombatDetachment(@RequestBody TFightInformationEntity tFightInformationEntity){
        List<TFightInformationEntity> list=tFightInformationService.totalCombatDetachment(tFightInformationEntity);
        return R.ok().put("list", list);
    }

    /*
     * 拼接sql
     * */
    private String doSql(List<PeopleEntityForm> tPeopleEntityList, String flag){
        StringBuffer sqlString=new StringBuffer();
        if(tPeopleEntityList !=null){
            if("0".equals(flag)) {
                for (PeopleEntityForm tPeopleForm : tPeopleEntityList) {
                    if ("name".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("peopleName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fp.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fp.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("deptName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and f.detachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and f.detachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("arrer".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.arrer " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.arrer " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("address".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.address " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.address " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("type".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.type " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.type " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("object".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.object " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.object " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("time".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("offTime".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.off_time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.off_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("stuation".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.stuation " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.stuation " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("countPeople".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.count_people " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.count_people " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("countvVehicle".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.count_vehicle " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.count_vehicle " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("dept".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fi.dept " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fi.dept " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("arrerName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and tf.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and tf.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("objectName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and td.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and td.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("typeName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("and fd.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("and fd.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                }
            } else{
                for (PeopleEntityForm tPeopleForm : tPeopleEntityList) {
                    if ("name".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("peopleName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fp.name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fp.name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("arrer".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.arrer " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.arrer " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("address".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.address " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.address " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("type".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.type " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.type " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("object".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.object " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.object " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("time".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.time " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("offTime".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.off_time" + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.off_time " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("stuation".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.stuation " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.stuation " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("countPeople".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.count_people " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.count_people " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("countvVehicle".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.count_vehicle " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.count_vehicle " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("dept".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fi.dept " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fi.dept " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("arrerName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or tf.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or tf.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("objectName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or td.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or td.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("typeName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or fd.type_name " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or fd.type_name " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                    if ("deptName".equals(tPeopleForm.getFour())) {
                        if("like".equals(tPeopleForm.getTwo()) || "not like".equals(tPeopleForm.getTwo())){
                            sqlString.append("or f.detachment " + tPeopleForm.getTwo() +"'"+'%'+tPeopleForm.getThree()+'%'+"'");
                        }else {
                            sqlString.append("or f.detachment " + tPeopleForm.getTwo() + "'" + tPeopleForm.getThree() + "'");
                        }
                    }
                }
            }
        }


        return sqlString.toString();
    }

}
